package com.mycompany.myapp.aop.logging.aop.test;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * Create by wys on 2018/8/4
 */
@Aspect
@Component
public class AopTestAfterThrowing {

//    @Pointcut("execution(* com.mycompany.myapp.web.rest" +.aoptestcontroller..AOPExceptionTestController.nullpoingexception(..))")
    @Pointcut("execution(* com.mycompany.myapp.web.rest.aoptestcontroller..AOPExceptionTestController.nullpoingexception(..))")
    public void executeService() {

    }

    /**
     *
     * @param joinPoint
     * @param exception
     */
    @AfterThrowing(value = "executeService()",throwing = "exception")
    public void doAfterThrwoingAdvice(JoinPoint joinPoint,Throwable exception) {
        System.out.println("joinPoint = " + joinPoint.getSignature().getName());
        try{

        }catch (Exception e) {
            e.printStackTrace();
        }
        if(exception instanceof NullPointerException) {
            System.out.println("xxx\"\" 发生了空指针异常 " );
        }
    }



//    @Before(value = "executeService()")
//    public void s() {
//        System.out.println(" ===== " );
//    }

}
